package com.joysuch.wwyt.api.alarmbluetooth.utils;

import org.springframework.stereotype.Component;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @program: wwyt-framework
 * @Description: 3.4 线程池
 * @author: aeiSaf
 * @create: 2020-07-13 20:27
 **/
@Component
public class ThreadPoolCommon {

    /**
     * 线程核心数量
     */
    private static final int API_CORE_POOL_SIZE = 10;
    /**
     * 最大线程数量
     */
    private static final int API_MAXIMUM_POOL_SIZE = 30;
    /**
     * 保持连接时长
     */
    private static final int API_KEEP_ALIVE_TIME = 1;
    /**
     * 线程等待数
     */
    private static final int API_CAPACITY = 300;

    private static final String API_PREFIX = "receive-alarm";

    private ThreadPoolExecutor pushThreads;

    public ThreadPoolExecutor threadPoolCommon() {
        return pushThreads = new ThreadPoolExecutor(API_CORE_POOL_SIZE, API_MAXIMUM_POOL_SIZE, API_KEEP_ALIVE_TIME, TimeUnit.HOURS,
                new LinkedBlockingQueue<>(API_CAPACITY), new NamedThreadFactory(API_PREFIX), (r, executor) -> {

        });
    }


}
